#ifndef DLGPCAPHUB_H
#define DLGPCAPHUB_H

#include <QDialog>
#include <QStandardItemModel>
#include "io/cap_thread.h"
#include "io/tcptunnel.h"
#include "tb_interface/cmdlineparser.h"
#include "tb_interface/tb_interface.h"
#include "tb_interface/listen_thread.h"
QT_BEGIN_NAMESPACE
namespace Ui { class DlgPCAPHub; }
QT_END_NAMESPACE

class DlgPCAPHub : public QDialog
{
	Q_OBJECT

public:
	DlgPCAPHub(TASKBUS::cmdlineParser & cmd,QWidget *parent = nullptr);
	~DlgPCAPHub();
public slots:
	void slot_msg(QString);
protected:
	void saveSettings();
	void loadSettings();
	void enumInterfaces();
	void timerEvent(QTimerEvent * evt) override;
private slots:
	void on_tableView_interfaces_clicked(const QModelIndex &index);
	void on_pushButton_startEnd_clicked();
	void on_checkBox_autoStart_clicked();

signals:
	void sig_msg(QString);
	void sig_start_tunnel(QString, QString,bool,bool);
	void sig_stop_tunnel();
private:
	Ui::DlgPCAPHub *ui;
	int m_nTimerID = -1;
	int m_nAutoStartID = -1;
	int m_nStartCounter = -1;
	QStandardItemModel * m_pInterfaceMod = nullptr;
	QStandardItemModel * m_pMsgMod = nullptr;
	QMap<QString,QString> m_devs;
	QMap<QString,int> m_devRows;
	QVector<cap_thread *> m_threads;
private:
	QThread * m_tunnelThread = nullptr;
	tcpTunnel * m_tunnel = nullptr;

	//Taskbus interface
protected:
	TASKBUS::cmdlineParser m_cmdline;
	int m_nTBIns = 0;
	listen_thread * m_pStdinThread = nullptr;
	cap_thread * m_pStdoutThread = nullptr;
};
#endif // DLGPCAPHUB_H
